<template>
    <div>
<table>
    <tbody>
        <tr>
            <td>名称</td>
            <td>
                <a style="color: red;">*</a>
                <input type="text" name="" id="" v-model="date.hname">
            </td>
        </tr>
        <tr>
            <td>启用</td>
            <td>

                <input type="checkbox" name="" v-model="date.state" id="" :value="true">
            </td>
        </tr>
        <tr>
            <td>时间</td>
            <td>
                <a style="color: red;">*</a>
                <input type="date" name="" id="" v-model="date.time">
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="button" value="保存" @click="add">
            </td>
            
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';

const router=useRouter()
const add=()=>{
if(date.value.hname==""){
alert('名称不能为空')
    return
}

if(date.value.time==""){
alert('时间不能为空')
    return
}

    axios.post('https://localhost:7019/api/Hospital/Add',date.value).then(res=>{
if(res.data>0){
alert('成功')
router.push({path:"/show"})
}else{
    alert('失败')
}

    })
}
const date=ref({
    "id": 0,
  "code": "",
  "hname": "",
  "isdel": true,
  "state": true,
  "time": ""
})
// const add=()=>{
//     axios.post('').then(res=>{

        
//     })
// }
</script>

<style scoped>

</style>